Skip to content

Conversation

@myftija
Copy link
Member

@myftija myftija commented Nov 14, 2025

This PR adds the --use-registry-cache flag to the deployment command. It enables using an external cache when using the local docker build. The registry must be supported as a cache storage backend.

@changeset-bot
Copy link

changeset-bot bot commented Nov 14, 2025

🦋 Changeset detected

Latest commit: 70292be

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 24 packages
Name Type
trigger.dev Patch
d3-chat Patch
references-d3-openai-agents Patch
references-nextjs-realtime Patch
references-realtime-streams Patch
@trigger.dev/build Patch
@trigger.dev/core Patch
@trigger.dev/python Patch
@trigger.dev/react-hooks Patch
@trigger.dev/redis-worker Patch
@trigger.dev/rsc Patch
@trigger.dev/schema-to-json Patch
@trigger.dev/sdk Patch
@trigger.dev/database Patch
@trigger.dev/otlp-importer Patch
@internal/cache Patch
@internal/clickhouse Patch
@internal/redis Patch
@internal/replication Patch
@internal/run-engine Patch
@internal/schedule-engine Patch
@internal/testcontainers Patch
@internal/tracing Patch
@internal/zod-worker Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 14, 2025

Walkthrough

This change adds external cache support for local image builds during deployment. A new --use-registry-cache CLI flag is introduced to the deploy command that enables registry-backed caching for build steps. The flag is propagated through the build pipeline via the useRegistryCache option in DeployCommandOptions and BuildImageOptions, then threaded into both local and remote build pathways. When enabled, the implementation injects Docker registry cache arguments (cache-to and cache-from) derived from the image tag for both local and self-hosted builds. A changeset documents the patch release with this new feature.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Cache reference derivation logic: Verify the getProjectCacheRefFromImageTag() helper correctly generates cache references from image tags
  • Dual build path implementation: Ensure registry cache arguments are consistently applied in both local and self-hosted/remote build codepaths
  • Mutual exclusivity validation: Confirm --use-registry-cache flag properly conflicts with --no-cache as intended
  • Option threading: Review the propagation of useRegistryCache through DeployCommandOptionsBuildImageOptions → concrete build implementations for correctness

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Description check ❓ Inconclusive The PR description provides basic context but lacks structure and completeness relative to the required template (missing checklist, testing details, and changelog sections). Complete the PR description using the template: include the checklist, document testing steps, provide a detailed changelog entry, and clarify registry backend requirements.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat(deployments): external cache support for local builds' accurately summarizes the main change—adding external cache support for local Docker builds via a new --use-registry-cache option.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch support-build-cache

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@myftija myftija merged commit 53047ab into main Nov 14, 2025
27 of 28 checks passed
@myftija myftija deleted the support-build-cache branch November 14, 2025 09:46
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (1)
packages/cli-v3/src/commands/deploy.ts (1)

116-128: Consider validating that --use-registry-cache is only used with local builds.

The flag is correctly implemented with proper mutual exclusivity. However, since useRegistryCache only affects local builds (not remote/depot builds), users might be confused if they use this flag without --force-local-build. The flag will be silently ignored for remote builds.

Consider adding validation in the _deployCommand function (after line 340 where isLocalBuild is determined) to warn users if they specify --use-registry-cache but a remote build is being performed:

if (options.useRegistryCache && !isLocalBuild) {
  log.warning("--use-registry-cache only works with local builds. Use --force-local-build to enable local builds.");
}
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between bb5cefa and 70292be.

📒 Files selected for processing (3)
  • .changeset/funny-ligers-wonder.md (1 hunks)
  • packages/cli-v3/src/commands/deploy.ts (3 hunks)
  • packages/cli-v3/src/deploy/buildImage.ts (8 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-08-20T07:41:13.973Z
Learnt from: nicktrn
Repo: triggerdotdev/trigger.dev PR: 2424
File: apps/supervisor/src/workloadManager/docker.ts:175-178
Timestamp: 2025-08-20T07:41:13.973Z
Learning: dockerode createImage() supports multiple signatures including createImage(auth, options) -> Promise<ReadableStream> where auth is the first parameter (AuthConfig object) and options is the second parameter. Both createImage(auth, options) and createImage(options, {authconfig: auth}) are valid approaches.

Applied to files:

  • packages/cli-v3/src/deploy/buildImage.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (22)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (7, 8)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (2, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (7, 8)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (5, 8)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (6, 8)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (3, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (1, 8)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (4, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (5, 8)
  • GitHub Check: units / internal / 🧪 Unit Tests: Internal (1, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (6, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (8, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (3, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (4, 8)
  • GitHub Check: units / webapp / 🧪 Unit Tests: Webapp (2, 8)
  • GitHub Check: units / packages / 🧪 Unit Tests: Packages (1, 1)
  • GitHub Check: e2e / 🧪 CLI v3 tests (windows-latest - pnpm)
  • GitHub Check: e2e / 🧪 CLI v3 tests (ubuntu-latest - pnpm)
  • GitHub Check: e2e / 🧪 CLI v3 tests (ubuntu-latest - npm)
  • GitHub Check: e2e / 🧪 CLI v3 tests (windows-latest - npm)
  • GitHub Check: typecheck / typecheck
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (7)
.changeset/funny-ligers-wonder.md (1)

1-5: LGTM!

The changeset is correctly formatted and accurately describes the new feature.

packages/cli-v3/src/commands/deploy.ts (2)

67-67: LGTM!

The useRegistryCache option is properly added to the schema with an appropriate default value.


428-469: LGTM!

The useRegistryCache option is correctly passed through to the buildImage function and will enable registry-backed caching for local builds.

packages/cli-v3/src/deploy/buildImage.ts (4)

19-19: LGTM!

The useRegistryCache option is correctly added to both BuildImageOptions and SelfHostedBuildImageOptions interfaces.

Also applies to: 313-313


54-110: LGTM!

The useRegistryCache option is properly destructured and passed to localBuildImage. It's intentionally not passed to remoteBuildImage since remote builds use Depot, which handles caching differently.


490-491: LGTM!

The project cache reference is correctly derived from the image tag for use in registry cache arguments.


500-507: LGTM!

The Docker buildx cache arguments are correctly formatted and conditionally added only when useRegistryCache is enabled. The use of mode=max, image-manifest=true, and oci-mediatypes=true for cache-to is appropriate for maximizing cache effectiveness with registry backends.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants